<?php
/**
 * 奖品管理活动与奖品多对多关联
 */
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateActivityPrizesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_prizes', function (Blueprint $table) {
            $table->uuid('id', 50)->unique();
            $table->uuid('activity_id');//活动id
            $table->uuid('prize_id');//奖品ID
            $table->float('surplus');//剩余库存
            $table->double('max_amount')->default(0);//最大面额
            $table->integer('winning_limit')->nullable();//中奖限制
            $table->float('stock_limit')->nullable();//库存限制
            $table->float('winning_probability')->nullable();//中奖概率
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('activity_prizes', function (Blueprint $table) {
            $table->dropIfExists();
        });
    }
}
